1
2
3
4
5
6
7 package gov.noaa.eds.xapi.generic.handlers;
8
9 import java.net.URL;
10
11 /***
12 * Handles resources.
13 * @version $Id: ResourceHandler.java,v 1.2 2004/12/23 23:39:15 mrxtravis Exp $
14 * @author tns
15 */
16 public class ResourceHandler extends UrlHandler {
17
18 private String resource = null;
19
20 /*** Creates a new instance of ResourceHandler */
21 public ResourceHandler() {
22 }
23
24 /***
25 * Getter for property resource.
26 * @return Value of property resource.
27 */
28 public String getResource() {
29
30 return this.resource;
31 }
32
33 /***
34 * Setter for property resource. It transformas the string into a URL
35 * before preceding to call {#setUrl}.
36 * @param resource New value of property resource.
37 */
38 public void setResource(String resource) {
39 if (resource == null){
40 throw new NullPointerException ("Parameter resource can not be null");
41 }
42 URL resourceUrl = this.getClass().getClassLoader().getResource(resource);
43 if (resourceUrl == null){
44 throw new NullPointerException("The specified resource:" + resource +
45 " could not be found.");
46 }
47 this.setUrl(resourceUrl);
48 this.resource = resource;
49
50 }
51
52 }